![]() |
PATH![]() |
![]() ![]() |
To save a reference of the form file nameString in a variable, you can use the A Reference To operator as shown in the example that follows.
tell application "Finder"
set fileRef to a reference to file "Hard Disk:June Sales"
--result: file "Hard Disk:June Sales" of application "Finder"
end tell
tell application "AppleWorks"
open fileRef
end
When you specify a file with a file reference, the file must exist at the time a statement that uses the reference is executed.
You cannot coerce a filename string to a file reference. For example, you cannot replace the second line of the previous script with the following line:
set fileRef to ("Hard Disk:June Sales" as file) --result: error!
However, you can perform a similar coercion with the alias form, as described in Specifying a File by Alias.